package com.jinyu.jyly.ui.mine.transfer;

import android.app.Activity;

import com.jinyu.jyly.base.BasePresenter;
import com.jinyu.jyly.bean.AllInfoBean;
import com.jinyu.jyly.net.DataManager;

import rx.Subscription;
import rx.functions.Action1;

public class TransferAccountPresenter extends BasePresenter<TransferAccountContract.View> implements TransferAccountContract.Presenter {

    public TransferAccountPresenter(Activity activity, TransferAccountContract.View view) {
        super(activity, view);

    }

    /**
     * 提交转账
     * @param param
     */
    @Override
    public void setTransfer(String param) {
        Subscription subscribe = DataManager.getInstance().setTransfer(param)
                .subscribe(new Action1<AllInfoBean>() {
                    @Override
                    public void call(AllInfoBean InfoData) {
                        if (InfoData != null) {
                            mView.onTransfer(InfoData);
                        }
                    }
                }, new Action1<Throwable>() {
                    @Override
                    public void call(Throwable throwable) {
                        throwable.printStackTrace();
                        mView.onFailer(throwable);
                    }
                });
        addSubscribe(subscribe);
    }

    /**
     * 验证身份证
     * @param param
     */
    @Override
    public void getUserName(String param) {
        Subscription subscribe = DataManager.getInstance().getNickName(param)
                .subscribe(new Action1<AllInfoBean>() {
                    @Override
                    public void call(AllInfoBean InfoData) {
                        if (InfoData != null) {
                            mView.onGetNickName(InfoData);
                        }
                    }
                }, new Action1<Throwable>() {
                    @Override
                    public void call(Throwable throwable) {
                        throwable.printStackTrace();
                        mView.onFailer(throwable);
                    }
                });
        addSubscribe(subscribe);
    }


}
